package com.xuecheng.basic.controller;

import com.xuecheng.commons.model.vo.DictionaryVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xuecheng.basic.service.DictionaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 数据字典前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
@RequestMapping("/dictionary")
public class DictionaryController {

    @Autowired
    private DictionaryService  dictionaryService;

    //查找所有数据字典
    @GetMapping
    public ResponseResult<List<DictionaryVo>> findAll() {
        return dictionaryService.findAll();
    }

    //根据code查询数据字典
    @GetMapping("/{code}")
    public ResponseResult<DictionaryVo> findByCode(@PathVariable("code") String code) {
        return dictionaryService.findByCode(code);
    }
}
